/*
 * 	Copyright © OpenAtom Foundation.
 * 	Licensed under the Apache License, Version 2.0 (the "License");
 * 	you may not use this file except in compliance with the License.
 * 	You may obtain a copy of the License at
 * 	     http://www.apache.org/licenses/LICENSE-2.0
 * 	Unless required by applicable law or agreed to in writing, software
 * 	distributed under the License is distributed on an "AS IS" BASIS,
 * 	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
 * 	See the License for the specific language governing permissions and
 * 	limitations under the License.
 *
 */

package com.inspur.edp.sgf.core.service;

import com.fasterxml.jackson.databind.JsonNode;
import com.inspur.edp.sgf.api.service.InvokeService;
import com.inspur.edp.sgf.core.manager.EapiInovkerMananger;
import com.inspur.edp.sgf.spi.ResourceInvokerParam;

import java.util.List;
import java.util.Map;

/**
 * 功能描述: @ClassName: InvokeServiceImpl @Author: Fynn Qi @Date: 2019/7/22 14:03 @Version: V1.0
 */
public class InvokeServiceImpl implements InvokeService {

    /**
     * 服务调用
     *
     * @param resourceType 资源类型
     * @param resourceId   资源ID
     * @param resourceOpId 资源操作ID
     * @param paramList    参数列表，JsonNode类型
     * @return 服务调用返回值
     */
    @Override
    public Object invokeByJsonNode(String resourceType, String resourceId, String resourceOpId, List<JsonNode> paramList) {
        return EapiInovkerMananger.invokeByJsonNode(resourceType, resourceId, resourceOpId, paramList);
    }

    /**
     * 服务调用
     *
     * @param resourceType
     * @param resourceId
     * @param resourceOpId
     * @param paramList
     * @param context
     * @return
     */
    @Override
    public Object invokeByJsonNode(String resourceType, String resourceId, String resourceOpId, List<JsonNode> paramList, Map<String, String> context) {
        ResourceInvokerParam param = new ResourceInvokerParam();
        param.setResourceType(resourceType);
        param.setResourceId(resourceId);
        param.setResourceOpId(resourceOpId);
        param.setNodeParams(paramList);
        param.setContextMap(context);
        return EapiInovkerMananger.invoke(param);
    }

}
